/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit5TestClass.java to edit this template
 */

package org.sbbs.dao;

import java.util.List;
import lombok.extern.slf4j.Slf4j;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.sbbs.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.history.Revisions;
import org.springframework.test.context.ActiveProfiles;

/**
 * 描述:<br/>
 * <br/>
 * 
 * Junit 5.x 说明描述用途及关键点,算法等
 * <p>
 * 创建时间: 2025年1月9日 18:27:17 <br/>
 * 作者: Mr.FDC <fdc_messenger@126.com> <br/>
 * 
 * <p>
 * 修改记录:<br/>
 * 1.aaaaaa<br/>
 * 2.bbbbbb<br/>
 */
@Slf4j
@SpringBootTest
@ActiveProfiles("simple")
public class PersonRepositoryTestSimple {

	@Autowired
	PersonRepository repo;

	@Test
	public void testSomeMethod() {
		Person john = new Person();
		john.setName("John");
                    
                john.setRemark("新建");
		// create
		Person saved = repo.save(john);
		
		
		assertThat(saved).isNotNull();

		saved.setName("Jonny-fdc");
                saved.setRemark("修改");
		// update
		Person updated = repo.save(saved);
		assertThat(updated).isNotNull();

		// delete
		repo.delete(updated);
		
		
		//read revison history records 
		Revisions<Long, Person> ls = repo.findRevisions(updated.getId());
		log.info(ls.toString());
               Assertions.assertTrue(ls.getContent().size()>0);
                
		// return updated;
	}

}